<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="../source/reset.css">
</head>
<style>
  .banner{
    width: 200px;
    height: 120px;
    border: 1px solid;
    margin: 1em auto;
    overflow: hidden;
    position: relative;
  }
  .banner .imgs{
    width: 600px;
    height: 120px;
  }
  .banner .imgs a{
    float: left;
  }
  .banner .imgs a img{
    width: 200px;
    height: 120px;
    object-fit: cover;
  }
  .banner .left,.banner .right{
    height: 20px;
    width: 20px;
    position: absolute;
    top: 0px;
    bottom: 0;
    margin: auto;
    text-align: center;
    line-height: 20px;
    color: #fff;
    
  }
  .banner .right{
    right: 0;
  }
  .banner .left{
    left: 0;
  }
  .banner .left:hover,.banner .right:hover{
    background-color: #fff;
    color: red;
    border-radius: 50%;
    cursor: pointer;
  }
  .banner .modal{
    position: absolute;
    left: 0;
    bottom:0;
    width: 200px;
    height: 20px;
    line-height: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 0 20px;
    box-sizing: border-box;
  }
  .banner .modal .title{
    padding: 0 4px;
    float: left;
    color: #fff;
    font-size: 10px;
  }

  .banner .modal .dots li{
    float: right;
  }

  .banner .modal .dots ul li{
    display: inline-block;
    border: 3px solid #fff;
    border-radius: 50%;
    margin: 5px 2px;
    cursor:pointer;
  }
  .banner .modal .dots ul li:hover{
    border: 3px solid greenyellow;
  }
  
</style>
<body>
  <div class="banner">
    <div class="imgs">
      <a href="">
        <img src="../source/imgs/img.webp" alt="">
      </a>
      <a href=""><img src="../source/imgs/图片1.jpg" alt=""></a>
      <a href=""><img src="../source/imgs/图片2.jpg" alt=""></a>
      <a href=""><img src="../source/imgs/图片3.jpg" alt=""></a>
    </div>
    <div class="left">&lt;</div>
    <div class="right">&gt;</div>
    <div class="modal">
      <div class="title">何以为家</div>
      <div class="dots">
        <ul>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
        </ul>
      </div>
    </div>
  </div>

  <script>
    let right = document.querySelector(".banner .right")
    right.addEventListener("click",(e)=>{
      let imgsStyle = document.querySelector(".banner .imgs").style;
      if(!imgsStyle.marginLeft){
        imgsStyle.marginLeft = "-200px";
      }else{
        imgsStyle.marginLeft = (parseFloat(imgsStyle.marginLeft.slice(0,-2)) - 200) + "px";
      }
    }, false);


    let left = document.querySelector(".banner .left")
    left.addEventListener("click",(e)=>{
      let imgsStyle = document.querySelector(".banner .imgs").style;
      if(!imgsStyle.marginLeft){
        imgsStyle.marginLeft = "200px";
      }else{
        imgsStyle.marginLeft = (parseFloat(imgsStyle.marginLeft.slice(0,-2)) + 200) + "px";
      }
    }, false);
  </script> 
</body>
</html>